<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
        1.传统累加
     */

    let values = [1, 2, 3, 4]

    function getSum() {
        let sum = 0;
        for (let i = 0; i < arguments.length; i++) {
            sum += arguments[i]
        }
        return sum;
    }

    console.log(getSum.apply(null, values))
    /*
        2.使用...扩展符
     */
    console.log(getSum(...values))

    /*
        3.在函数中, ...values,应该放在最后一个
     */
    function fn(firstValue, ...restValue) {
    }

    /*
        4.箭头函数虽然不支持arguments,但是可以实现一样的逻辑
     */
    let getSum2 = (...values) => values.reduce((x, y) => x + y, 0)
</script>
</body>
</html>